package cn.edu.xmu.restfuldemo.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品视图对象
 * @author Ming Qiu
 **/
@Data
@ApiModel(description = "商品对象")
@NoArgsConstructor
public class GoodsRetVo {

//    public void setId(Integer id) {
//        this.id = id;
//    }

    @ApiModelProperty(value = "商品id")
    private Integer id;

    @ApiModelProperty(value = "商品序号")
    private String goodsSn;

    @ApiModelProperty(value = "商品名称")
    private String name;


    @ApiModelProperty(value = "商品图片")
    private String imageUrl;

    @ApiModelProperty(value = "商品状态")
    private Integer state;

    @ApiModelProperty("是否禁止访问")
    private boolean disabled;

    private String gmtCreate;
    private String gmtModified;

//    @ApiModelProperty(value = "商品规格")
//    private List<ProductRetVo> productList;

    /**
     * 构造函数，由Goods对象创建Vo
     * @param goods goods对象
     */
    public GoodsRetVo(Goods goods) {
        this.id = goods.getId();
        this.goodsSn = goods.getGoodsSn();
        this.name = goods.getName();
        this.disabled = false;
        this.gmtCreate=null;
        this.gmtModified = null;
//        this.brief = goods.getBrief();
//        this.unit = goods.getUnit();
        this.imageUrl = goods.getPicUrl();
//        this.specList = goods.getSpecList();
//        this.brandId = goods.getBrandId();
//        this.categoryId = goods.getCategoryId();
        this.state = null;
//        if (null != goods.getState()) {
//            this.state = goods.getState().getDescription();
//        }
//        if (null != goods.getProductList()) {
//            List<ProductRetVo> productList = new ArrayList<>(goods.getProductList().size());
//
//            for (Product product : goods.getProductList()) {
//                ProductRetVo productVo = new ProductRetVo(product);
//                productList.add(productVo);
//            }
//            this.productList = productList;
//        }
    }
}
